/**
 * 
 */
package pl.edu.mimuw.irs.core.model.design.net.refinement;

import pl.edu.mimuw.irs.core.model.design.exception.InternalDesignException;
import pl.edu.mimuw.irs.core.model.design.exception.InternalDesignException.DesignCause;
import pl.edu.mimuw.irs.core.model.design.net.IRSActivity;
import pl.edu.mimuw.irs.core.model.design.net.IRSNode;
import pl.edu.mimuw.irs.core.model.design.net.IRSRequirement;
import pl.edu.mimuw.irs.core.model.design.net.IRSTransition;

/**
 * @author Jakub Rauch
 * Created on: 2010-03-08
 */
public class IRSActivityChildren extends IRSAbstractLoopingChildren {

	private static final long serialVersionUID = -1379754755674972878L;
	
	// *** Attributes

	private IRSActivity activity;
	private IRSRequirement requirement;
	public IRSActivity getActivity() {
		return this.activity;
	}
	public IRSRequirement getRequirement() {
		return this.requirement;
	}
	public Refinement getRefinement() {
		return Refinement.ACTIVITY;
	};
	
	// *** Constructors

	/**
	 * @param node
	 */
	public IRSActivityChildren(IRSActivityChildren node) {
		/** FIXME: empty */
		super(node);
	}
	
	/**
	 * @param node
	 */
	public IRSActivityChildren(IRSTransition node) {
		/** FIXME: empty */
		super(node);
	}
	
	// *** Methods
	
	protected IRSNode createIdentical(IRSNode node, boolean deep) {
		if (node instanceof IRSTransition) {
			if (!deep) return this.activity = new IRSActivity(node.getIdManager()); // TODO : change it to make the shallow copy more flexible.
			return this.activity = new IRSActivity((IRSTransition) node);
		}
		else throw new InternalDesignException(DesignCause.UNKNOWN_NODE_TYPE, "Node " + node + " should be an IRSTransition.", this);
	}
	
	protected IRSNode createOpposite(IRSNode node) {
		if (node instanceof IRSTransition) return this.requirement = new IRSRequirement(node.getIdManager());
		else throw new InternalDesignException(DesignCause.UNKNOWN_NODE_TYPE, "Node " + node + " should be an IRSTransition.", this);
	}
	
	@Override
	public IRSAbstractChildren clone() {
		return new IRSActivityChildren(this);
	}
}
